home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / Source.bin / WrappingLabelBeanInfo.java < prev    next >
Text File  |  1998-08-21  |  7KB  |  205 lines

  1. package symantec.itools.awt;
  2.  
  3. import java.beans.*;
  4. import symantec.itools.beans.*;
  5. import java.util.ResourceBundle;
  6.  
  7. //  09/07/97    LAB    Fixed misspelling of descriptions.
  8. //  08/19/98    LAB    Moved to GroupAWTAdditions folder.
  9.  
  10. /**
  11.  * BeanInfo for WrappingLabel.
  12.  *
  13.  */
  14. public class WrappingLabelBeanInfo extends SimpleBeanInfo {
  15.  
  16.     /**
  17.      * Constructs a WrappingLabelBeanInfo object.
  18.      */
  19.     public WrappingLabelBeanInfo() {
  20.     }
  21.  
  22.     /**
  23.      * Gets a BeanInfo for the superclass of this bean.
  24.      * @return BeanInfo[] containing this bean's superclass BeanInfo
  25.      */
  26.     public BeanInfo[] getAdditionalBeanInfo() {
  27.         try {
  28.             BeanInfo[] bi = new BeanInfo[1];
  29.             bi[0] = Introspector.getBeanInfo(beanClass.getSuperclass());
  30.             return bi;
  31.         }
  32.         catch (IntrospectionException e) { throw new Error(e.toString());}
  33.     }
  34.  
  35.     /**
  36.      * Gets the SymantecBeanDescriptor for this bean.
  37.      * @return an object of type SymantecBeanDescriptor
  38.      * @see symantec.itools.beans.SymantecBeanDescriptor
  39.      */
  40.     public BeanDescriptor getBeanDescriptor() {
  41.         ResourceBundle group = ResourceBundle.getBundle("symantec.itools.resources.GroupBundle");
  42.         String s=group.getString("GroupAWTAdditions"); 
  43.  
  44.         SymantecBeanDescriptor bd = new SymantecBeanDescriptor(beanClass);
  45.         bd.setFolder(s);
  46.         bd.setToolbar(s);
  47.         bd.setWinHelp("0x123A9");
  48.  
  49.         ResourceBundle conn = ResourceBundle.getBundle("symantec.itools.resources.ConnBundle");
  50.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
  51.                                                 "%name%.ALIGN_LEFT",
  52.                                                 conn.getString("ALIGN_LEFT")));
  53.  
  54.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
  55.                                                 "%name%.ALIGN_CENTERED",
  56.                                                 conn.getString("ALIGN_CENTERED")));
  57.  
  58.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
  59.                                                 "%name%.ALIGN_RIGHT",
  60.                                                 conn.getString("ALIGN_RIGHT")));
  61.  
  62.  
  63.         return (BeanDescriptor) bd;
  64.     }
  65.  
  66.     /**
  67.      * Gets an image that may be used to visually represent this bean
  68.      * (in the toolbar, on a form, etc).
  69.      * @param iconKind the type of icon desired, one of: BeanInfo.ICON_MONO_16x16,
  70.      * BeanInfo.ICON_COLOR_16x16, BeanInfo.ICON_MONO_32x32, or BeanInfo.ICON_COLOR_32x32.
  71.      * @return an image for this bean, always color even if requested monochrome
  72.      * @see BeanInfo#ICON_MONO_16x16
  73.      * @see BeanInfo#ICON_COLOR_16x16
  74.      * @see BeanInfo#ICON_MONO_32x32
  75.      * @see BeanInfo#ICON_COLOR_32x32
  76.      */
  77.     public java.awt.Image getIcon(int iconKind) {
  78.         if (iconKind == BeanInfo.ICON_MONO_16x16 ||
  79.             iconKind == BeanInfo.ICON_COLOR_16x16) {
  80.             java.awt.Image img = loadImage("WrappingLabelC16.gif");
  81.             return img;
  82.         }
  83.  
  84.         if (iconKind == BeanInfo.ICON_MONO_32x32 ||
  85.             iconKind == BeanInfo.ICON_COLOR_32x32) {
  86.             java.awt.Image img = loadImage("WrappingLabelC32.gif");
  87.             return img;
  88.         }
  89.  
  90.         return null;
  91.     }
  92.  
  93.     /**
  94.      * Gets an array of descriptions of the methods used for "connections" by
  95.      * Visual CafΘ's Interaction Wizard.
  96.      * Included in each method description is a CONNECTIONS ConnectionDescriptor.
  97.      * @return method descriptions for this bean
  98.      * @see symantec.itools.beans.ConnectionDescriptor#CONNECTIONS
  99.      */
  100.     public MethodDescriptor[] getMethodDescriptors() {
  101.         Class[] args;
  102.         ConnectionDescriptor connection;
  103.         java.util.Vector connections;
  104.         java.util.Vector md = new java.util.Vector();
  105.         ResourceBundle conn = ResourceBundle.getBundle("symantec.itools.resources.ConnBundle");
  106.  
  107.         try{
  108.             args = new Class[1];
  109.             args[0] = java.lang.String.class ;
  110.             MethodDescriptor setText = new MethodDescriptor(beanClass.getMethod("setText", args));
  111.  
  112.             connections = new java.util.Vector();
  113.             connection = new ConnectionDescriptor("input", "String", "",
  114.                                     "%name%.setText(%arg%);",
  115.                                     conn.getString("setText"));
  116.             connections.addElement(connection);
  117.  
  118.             setText.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  119.             md.addElement(setText);
  120.         } catch (Exception e) { throw new Error("setText:: " + e.toString()); }
  121.  
  122.         try{
  123.             args = new Class[1];
  124.             args[0] = java.lang.Integer.TYPE ;
  125.             MethodDescriptor setAlignStyle = new MethodDescriptor(beanClass.getMethod("setAlignStyle", args));
  126.  
  127.             connections = new java.util.Vector();
  128.             connection = new ConnectionDescriptor("input", "int", "",
  129.                                     "%name%.setAlignStyle(%arg%);",
  130.                                     conn.getString("setAlignStyleText"));
  131.             connections.addElement(connection);
  132.  
  133.             setAlignStyle.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  134.             md.addElement(setAlignStyle);
  135.         } catch (Exception e) { throw new Error("setAlignStyle:: " + e.toString()); }
  136.  
  137.         try{
  138.             args = null;
  139.             MethodDescriptor getText = new MethodDescriptor(beanClass.getMethod("getText", args));
  140.  
  141.             connections = new java.util.Vector();
  142.             connection = new ConnectionDescriptor("output", "String", "",
  143.                                     "%name%.getText()",
  144.                                     conn.getString("getText"));
  145.             connections.addElement(connection);
  146.  
  147.             getText.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  148.             md.addElement(getText);
  149.         } catch (Exception e) { throw new Error("getText:: " + e.toString()); }
  150.  
  151.         try{
  152.             args = null;
  153.             MethodDescriptor getAlignStyle = new MethodDescriptor(beanClass.getMethod("getAlignStyle", args));
  154.  
  155.             connections = new java.util.Vector();
  156.             connection = new ConnectionDescriptor("output", "int", "",
  157.                                     "%name%.getAlignStyle()",
  158.                                     conn.getString("getAlignStyleText"));
  159.             connections.addElement(connection);
  160.  
  161.             getAlignStyle.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  162.             md.addElement(getAlignStyle);
  163.         } catch (Exception e) { throw new Error("getAlignStyle:: " + e.toString()); }
  164.  
  165.         MethodDescriptor[] rv = new MethodDescriptor[md.size()];
  166.         md.copyInto(rv);
  167.  
  168.         return rv;
  169.     }
  170.  
  171.     /**
  172.      * Returns descriptions of this bean's properties.
  173.      */
  174.     public PropertyDescriptor[] getPropertyDescriptors() {
  175.         ResourceBundle prop = ResourceBundle.getBundle("symantec.itools.resources.PropBundle");
  176.  
  177.         try{
  178.         PropertyDescriptor defProperty = new PropertyDescriptor("text", beanClass);
  179.         defProperty.setBound(true);
  180.         defProperty.setConstrained(true);
  181.         defProperty.setDisplayName(prop.getString("text"));
  182.  
  183.         PropertyDescriptor alignStyle = new PropertyDescriptor("alignStyle", beanClass);
  184.         alignStyle.setBound(true);
  185.         alignStyle.setConstrained(true);
  186.         alignStyle.setDisplayName(prop.getString("alignStyle"));
  187.         alignStyle.setValue("ENUMERATION", "ALIGN_LEFT=0, ALIGN_CENTERED=1, ALIGN_RIGHT=2");
  188.  
  189.         PropertyDescriptor[] rv = {
  190.             defProperty,
  191.             alignStyle};
  192.         return rv;
  193.         } catch (IntrospectionException e) { throw new Error(e.toString()); }
  194.     }
  195.  
  196.     /**
  197.      * Returns the index of the property expected to be changed most often by the designer.
  198.      */
  199.     public int getDefaultPropertyIndex() {
  200.         return 0;    //  the index for our default property is always 0
  201.     }
  202.  
  203.     private final static Class beanClass = WrappingLabel.class;
  204.  
  205.     }    //  end of class WrappingLabelBeanInfo